package com.ruoyi.web.controller.tableSettings;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SelfServiceMiniProgramSettings;
import com.ruoyi.system.service.ISelfServiceMiniProgramSettingsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 自助小程序设置(含联系方式和分时段预订)Controller
 *
 * @author ruoyi
 * @date 2025-05-20
 */
@Api(tags="自助小程序设置")
@RestController
@RequestMapping("/system/selfServiceMiniProgramSettings")
public class SelfServiceMiniProgramSettingsController extends BaseController
{
    @Autowired
    private ISelfServiceMiniProgramSettingsService selfServiceMiniProgramSettingsService;

    /**
     * 查询自助小程序设置列表
     */
    @ApiOperation("查询自助小程序设置列表")
    @PreAuthorize("@ss.hasPermi('system:settings:list')")
    @GetMapping("/list")
    public TableDataInfo list(SelfServiceMiniProgramSettings selfServiceMiniProgramSettings)
    {
        startPage();
        List<SelfServiceMiniProgramSettings> list = selfServiceMiniProgramSettingsService.selectSelfServiceMiniProgramSettingsList(selfServiceMiniProgramSettings);
        return getDataTable(list);
    }

    /**
     * 导出自助小程序设置列表
     */
    @ApiOperation("导出自助小程序设置列表")
    @PreAuthorize("@ss.hasPermi('system:settings:export')")
    @Log(title = "自助小程序设置(含联系方式和分时段预订)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SelfServiceMiniProgramSettings selfServiceMiniProgramSettings)
    {
        List<SelfServiceMiniProgramSettings> list = selfServiceMiniProgramSettingsService.selectSelfServiceMiniProgramSettingsList(selfServiceMiniProgramSettings);
        ExcelUtil<SelfServiceMiniProgramSettings> util = new ExcelUtil<SelfServiceMiniProgramSettings>(SelfServiceMiniProgramSettings.class);
        util.exportExcel(response, list, "自助小程序设置(含联系方式和分时段预订)数据");
    }

    /**
     * 通过id获取自助小程序设置详细信息
     */
    @ApiOperation("通过id获取自助小程序设置详细信息")
    @PreAuthorize("@ss.hasPermi('system:settings:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(selfServiceMiniProgramSettingsService.selectSelfServiceMiniProgramSettingsById(id));
    }

    /**
     * 新增自助小程序设置
     */
    @ApiOperation("新增自助小程序设置")
    @PreAuthorize("@ss.hasPermi('system:settings:add')")
    @Log(title = "自助小程序设置(含联系方式和分时段预订)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SelfServiceMiniProgramSettings selfServiceMiniProgramSettings)
    {
        return toAjax(selfServiceMiniProgramSettingsService.insertSelfServiceMiniProgramSettings(selfServiceMiniProgramSettings));
    }

    /**
     * 修改自助小程序设置
     */
    @ApiOperation("修改自助小程序设置")
    @PreAuthorize("@ss.hasPermi('system:settings:edit')")
    @Log(title = "自助小程序设置(含联系方式和分时段预订)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SelfServiceMiniProgramSettings selfServiceMiniProgramSettings)
    {
        return toAjax(selfServiceMiniProgramSettingsService.updateSelfServiceMiniProgramSettings(selfServiceMiniProgramSettings));
    }

    /**
     * 通过id批量删除自助小程序设置信息
     */
    @ApiOperation("通过id批量删除自助小程序设置信息")
    @PreAuthorize("@ss.hasPermi('system:settings:remove')")
    @Log(title = "自助小程序设置(含联系方式和分时段预订)", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(selfServiceMiniProgramSettingsService.deleteSelfServiceMiniProgramSettingsByIds(ids));
    }
}
